VERSION 5.00
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "ITGControls.ocx"
Begin VB.Form frmReportWriter 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Report Writer"
   ClientHeight    =   8175
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   9645
   Icon            =   "frmReportWriter.frx":0000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   8175
   ScaleWidth      =   9645
   Begin VB.ListBox List1 
      Appearance      =   0  'Flat
      Height          =   2175
      Left            =   225
      TabIndex        =   23
      Top             =   5760
      Width           =   2655
   End
   Begin VB.ListBox List2 
      Appearance      =   0  'Flat
      Height          =   2175
      Left            =   3780
      TabIndex        =   21
      Top             =   5760
      Width           =   2775
   End
   Begin VB.OptionButton Option2 
      Caption         =   "Stored Procedure"
      Height          =   300
      Left            =   2025
      TabIndex        =   3
      Top             =   1305
      Width           =   1665
   End
   Begin VB.OptionButton Option1 
      Caption         =   "Query Builder"
      Height          =   300
      Left            =   300
      TabIndex        =   2
      Top             =   1305
      Width           =   1665
   End
   Begin TabDlg.SSTab SSTab1 
      Height          =   3705
      Left            =   135
      TabIndex        =   14
      Top             =   1695
      Width           =   9360
      _ExtentX        =   16510
      _ExtentY        =   6535
      _Version        =   393216
      TabOrientation  =   2
      Tabs            =   2
      TabsPerRow      =   2
      TabHeight       =   520
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      TabCaption(0)   =   "Query Builder"
      TabPicture(0)   =   "frmReportWriter.frx":0CCA
      Tab(0).ControlEnabled=   -1  'True
      Tab(0).Control(0)=   "Label1"
      Tab(0).Control(0).Enabled=   0   'False
      Tab(0).Control(1)=   "cmdQueryTest"
      Tab(0).Control(1).Enabled=   0   'False
      Tab(0).Control(2)=   "txtWizards"
      Tab(0).Control(2).Enabled=   0   'False
      Tab(0).Control(3)=   "txtRemarks"
      Tab(0).Control(3).Enabled=   0   'False
      Tab(0).ControlCount=   4
      TabCaption(1)   =   "Stored Procedure"
      TabPicture(1)   =   "frmReportWriter.frx":0CE6
      Tab(1).ControlEnabled=   0   'False
      Tab(1).Control(0)=   "ITGCommandButton4"
      Tab(1).Control(1)=   "ITGTextBox2"
      Tab(1).Control(2)=   "dtgPR"
      Tab(1).ControlCount=   3
      Begin VB.TextBox txtRemarks 
         Appearance      =   0  'Flat
         Height          =   2355
         Left            =   585
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   24
         Text            =   "frmReportWriter.frx":0D02
         Top             =   540
         Width           =   8490
      End
      Begin ITGControls.ITGCommandButton txtWizards 
         Height          =   375
         Left            =   1230
         TabIndex        =   15
         Top             =   3120
         Width           =   1335
         _ExtentX        =   2355
         _ExtentY        =   661
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Caption         =   "Wizards"
      End
      Begin MSDataGridLib.DataGrid dtgPR 
         Height          =   1950
         Left            =   -74400
         TabIndex        =   6
         Top             =   1035
         Width           =   8520
         _ExtentX        =   15028
         _ExtentY        =   3440
         _Version        =   393216
         AllowUpdate     =   -1  'True
         AllowArrows     =   -1  'True
         BackColor       =   16777215
         HeadLines       =   1
         RowHeight       =   15
         TabAcrossSplits =   -1  'True
         TabAction       =   2
         FormatLocked    =   -1  'True
         AllowDelete     =   -1  'True
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   4
         BeginProperty Column00 
            DataField       =   "cParameter"
            Caption         =   "Parameter Name"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   "cVarType"
            Caption         =   "Var Type"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   "0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column02 
            DataField       =   "nLength"
            Caption         =   "Length"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column03 
            DataField       =   "cRemarks"
            Caption         =   "Remarks"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
               Locked          =   -1  'True
               ColumnWidth     =   2610.142
            EndProperty
            BeginProperty Column01 
               Button          =   -1  'True
               ColumnWidth     =   1409.953
            EndProperty
            BeginProperty Column02 
               Locked          =   -1  'True
               ColumnWidth     =   975.118
            EndProperty
            BeginProperty Column03 
               Locked          =   -1  'True
               ColumnWidth     =   3209.953
            EndProperty
         EndProperty
      End
      Begin ITGControls.ITGTextBox ITGTextBox2 
         Height          =   285
         Left            =   -74415
         TabIndex        =   5
         Top             =   465
         Width           =   8520
         _ExtentX        =   14817
         _ExtentY        =   503
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Label           =   "Stored Procedure"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1400
         TextBoxWidth    =   7060
      End
      Begin ITGControls.ITGCommandButton ITGCommandButton4 
         Height          =   375
         Left            =   -67350
         TabIndex        =   7
         Top             =   3105
         Width           =   1470
         _ExtentX        =   2593
         _ExtentY        =   661
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Caption         =   "&Test Connection"
      End
      Begin ITGControls.ITGCommandButton cmdQueryTest 
         Height          =   375
         Left            =   7665
         TabIndex        =   4
         Top             =   3120
         Width           =   1440
         _ExtentX        =   2540
         _ExtentY        =   661
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Caption         =   "Test Connection"
      End
      Begin VB.Label Label1 
         Caption         =   "Select Statement"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   705
         TabIndex        =   16
         Top             =   210
         Width           =   2895
      End
   End
   Begin VB.Frame Frame1 
      Height          =   1095
      Left            =   150
      TabIndex        =   13
      Top             =   105
      Width           =   9360
      Begin ITGControls.ITGTextBox txtSubject 
         Height          =   285
         Left            =   270
         TabIndex        =   0
         Top             =   255
         Width           =   8520
         _ExtentX        =   14817
         _ExtentY        =   503
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Label           =   "Report Name"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1400
         TextBoxWidth    =   7060
      End
      Begin ITGControls.ITGTextBox txtFileName 
         Height          =   285
         Left            =   270
         TabIndex        =   1
         Top             =   630
         Width           =   8520
         _ExtentX        =   14817
         _ExtentY        =   503
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Label           =   "Filename"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1400
         TextBoxWidth    =   7060
      End
   End
   Begin ITGControls.ITGCommandButton cmdExit 
      Height          =   375
      Left            =   7875
      TabIndex        =   12
      Top             =   7545
      Width           =   1335
      _ExtentX        =   2355
      _ExtentY        =   661
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "E&xit"
   End
   Begin ITGControls.ITGCommandButton ITGCommandButtonFinish 
      Height          =   375
      Left            =   7875
      TabIndex        =   11
      Top             =   7095
      Width           =   1335
      _ExtentX        =   2355
      _ExtentY        =   661
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "Finish"
   End
   Begin ITGControls.ITGCommandButton ITGCommandButtonRemoveAll 
      Height          =   495
      Left            =   3060
      TabIndex        =   17
      ToolTipText     =   "Remove All Field Name"
      Top             =   7320
      Width           =   555
      _ExtentX        =   979
      _ExtentY        =   873
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "<<"
   End
   Begin ITGControls.ITGCommandButton ITGCommandButtonRemoveFld 
      Height          =   495
      Left            =   3060
      TabIndex        =   18
      ToolTipText     =   "Remove Field"
      Top             =   6840
      Width           =   555
      _ExtentX        =   979
      _ExtentY        =   873
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "<"
   End
   Begin ITGControls.ITGCommandButton ITGCommandButtonCopyAll 
      Height          =   495
      Left            =   3060
      TabIndex        =   19
      ToolTipText     =   "Move All Field Name"
      Top             =   6360
      Width           =   555
      _ExtentX        =   979
      _ExtentY        =   873
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   ">>"
   End
   Begin ITGControls.ITGCommandButton ITGCommandButtonCopyFld 
      Height          =   495
      Left            =   3060
      TabIndex        =   20
      ToolTipText     =   "Move Field Name"
      Top             =   5880
      Width           =   555
      _ExtentX        =   979
      _ExtentY        =   873
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   ">"
   End
   Begin ITGControls.ITGLabel ITGLabel3 
      Height          =   285
      Left            =   225
      TabIndex        =   22
      Top             =   5460
      Width           =   1275
      _ExtentX        =   2249
      _ExtentY        =   503
      Caption         =   "Fields Definition "
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin ITGControls.ITGCommandButton cmdFieldDef 
      Height          =   375
      Left            =   7230
      TabIndex        =   8
      Top             =   5535
      Width           =   2250
      _ExtentX        =   3969
      _ExtentY        =   661
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "Create Fields Definition"
   End
   Begin ITGControls.ITGCommandButton cmdPreview 
      Height          =   375
      Left            =   7875
      TabIndex        =   10
      Top             =   6645
      Width           =   1335
      _ExtentX        =   2355
      _ExtentY        =   661
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "Preview"
   End
   Begin ITGControls.ITGCommandButton cmdCreateRep 
      Height          =   375
      Left            =   7875
      TabIndex        =   9
      Top             =   6210
      Width           =   1335
      _ExtentX        =   2355
      _ExtentY        =   661
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "Create Report"
   End
End
Attribute VB_Name = "frmReportWriter"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'IT Group Inc. 2005.09.23

Option Explicit



'ADO Connection variables

Private connRep As ADODB.Connection

Dim rsRep As ADODB.Recordset
Attribute rsRep.VB_VarHelpID = -1

Private Sub cmdCreateRep_Click()
On Error GoTo HandleErr

    If CreateReportOnRuntimeDS(rsRep, App.Path & "\" & txtFileName.Text & ".rpt", App.Path & txtFileName.Text & ".ttx", True, True) <> 0 Then
        MsgBox "Field definition created, continue creating report.  Save report before previewing"
    Else
        MsgBox "Failed to create Field Definition"
    End If

HandleErr:
    Select Case err.Number
        Case 0
        Case Else
            MsgBox "Error " & err.Number & ": " & err.Description, vbCritical, "f00_DynamoReport1.cmdcreate_Click"  'ErrorHandler:$$N=f00_DynamoReport1.cmdcreate_Click
    End Select
End Sub

Private Sub cmdExit_Click()
    Unload Me
End Sub

Private Sub cmdFieldDef_Click()
On Error GoTo HandleErr

    If CreateFieldDefFile(rsRep, App.Path & "\" & txtFileName.Text & ".ttx", True) <> 0 Then
        MsgBox "Field definition successfully created"
    Else
        MsgBox "Failed to create field definition file"
    End If
    
HandleErr:
    Select Case err.Number
        Case 0
        Case Else
            MsgBox "Error " & err.Number & ": " & err.Description, vbCritical, "f00_DynamoReport1.cmdFieldDef_Click"    'ErrorHandler:$$N=f00_DynamoReport1.cmdFieldDef_Click
    End Select
End Sub

Private Sub cmdPreview_Click()
On Error GoTo HandleErr
    frmReportWriterViewer.Show

HandleErr:
    Select Case err.Number
        Case 0
        Case Else
            MsgBox "Error " & err.Number & ": " & err.Description, vbCritical, "f00_DynamoReport1.cmdReport_Click"  'ErrorHandler:$$N=f00_DynamoReport1.cmdReport_Click
    End Select
End Sub

Private Sub cmdQueryTest_Click()
On Error GoTo HandleErr
    
    OpenNewConnection connRep

    rsRep.CursorLocation = adUseClient
    
    rsRep.Open Trim(txtRemarks), _
            connRep, adOpenStatic, adLockBatchOptimistic

    If rsRep.RecordCount < 1 Then
        MsgBox "No Records for your query were found.", vbInformation, "Try New Query."
    Else
        MsgBox "Query Successful", vbExclamation, "Success"
    End If

HandleErr:
    Select Case err.Number
        Case 0
        Case Else
            MsgBox "Error " & err.Number & ": " & err.Description, vbCritical, "f00_DynamoReport1.cmdConnect_Click" 'ErrorHandler:$$N=f00_DynamoReport1.cmdConnect_Click
    End Select
End Sub

Private Sub Form_Load()
    Set rsRep = New ADODB.Recordset
    OpenNewConnection connRep
End Sub

Private Sub Form_Unload(Cancel As Integer)
    
    Set rsRep = Nothing
    Set connRep = Nothing
    Set frmReportWriter = Nothing
    lCloseWindow = True
End Sub

Private Sub Option1_Click()
    Me.SSTab1.Tab = 0
    Me.SSTab1.TabEnabled(1) = False
    Me.SSTab1.TabEnabled(0) = True
End Sub

Private Sub Option2_Click()
    Me.SSTab1.Tab = 1
    Me.SSTab1.TabEnabled(1) = True
    Me.SSTab1.TabEnabled(0) = False
End Sub

Private Sub txtWizards_Click()
    frmQueryBuilder.Show
    Me.txtRemarks.Text = frmQueryBuilder.tmpSQL
End Sub
